/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2022-03-27 22:53:57
 * @LastEditTime: 2025-04-18 22:12:46
 */
import { defineConfig, ConfigEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig(({ }: ConfigEnv) => {
  return {
    base: './',
    plugins: [
      react(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(__dirname, 'src/assets/icons')],
        symbolId: 'icon-[name]',
    }),
    ],
    server: {
      port: 8899,
      open: true,
      host: '0.0.0.0',
      proxy: {
          '/api': {
              target: 'http://117.50.174.187:9528/iot/api',
              changeOrigin: true,
              rewrite: (path) => path.replace(/^\/api/, ""),
          }
      }
  },
    resolve: {
    
      alias: [
        {
          find: '@',
          replacement: '/src'
        },
        {
          find:/^~/,replacement:''
        }
      ]
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
          charset: false,
          additionalData: '@import "./src/styles/theme.less";',
        }
      }
    },
    build: {
      terserOptions: {
        compress: {
          drop_console: true
        }
      },
      outDir: 'dist', //指定输出路径
      assetsDir: 'assets' //指定生成静态资源的存放路径
    }
  };
});
